package com.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.awt.print.Book;

@Slf4j
//Rest模式
@RestController
@RequestMapping("/books")
public class BookController{

    //创建记录日志对象
//    private static final Logger log = LoggerFactory.getLogger(BookController.class);

    @PostMapping
    public String save(@RequestBody Book book) {
        System.out.println("user save..." + book);
        return "{'module':'user save'}";
    }

    @DeleteMapping("/{id}")
    public String delete(@PathVariable Integer id) {
        System.out.println("user delete..." + id);
        return "{'module':'user delete'}";
    }

    @PutMapping
    public String update(@RequestBody Book book) {
        System.out.println("book update..." + book);
        return "{'module':'book update'}";
    }

    @GetMapping("/{id}")
    public String getBuyId(@PathVariable Integer id) {
        System.out.println("book getBuyId..." + id);

        log.debug("debug...");
        log.info("info...");
        log.warn("warn...");
        log.error("error...");

        return "{'module':'book getBuyId'}";
    }

    @GetMapping
    public String geAll() {
        System.out.println("book geAll...");
        return "{'module':'book geAll'}";
    }
}